class UserUtil {
  get() {
    let user = JSON.parse(sessionStorage.getItem("userInfo"));
    // let user = JSON.parse(localStorage.getItem("userInfo"));

    // console.log(user)
    return user;
  }

  set(data) {
    let user = JSON.parse(sessionStorage.getItem("userInfo"));
    // let user = JSON.parse(localStorage.getItem("userInfo"));
    if (user != null && user != "" && "undefined" != typeof user) {
      data = new Object(data);

      if (
        data.tokenId == null ||
        data.tokenId == "" ||
        "undefined" == typeof data.tokenId
      ) {
        data.tokenId = user.tokenId;
      }
    }
    sessionStorage.setItem("userInfo", JSON.stringify(data));
    // localStorage.setItem("userInfo", JSON.stringify(data));
  }

  isLogin() {
    let user = this.get();
    if (user == null || "undefined" == typeof user) {
      return false;
    } else {
      return true;
    }
  }

  isNotLogin() {
    let user = this.get();
    if (user == null || "undefined" == typeof user) {
      return true;
    } else {
      return false;
    }
  }

  refreshUserInfo() {
    //
    // return sendPost(api.refreshUserInfo, new Object)
  }
}

export default new UserUtil();
